<template>
<<<<<<< HEAD
<div>
  <el-table :data="lists" border style="width: 100%">
    <el-table-column fixed prop="number" label="试题编号" width="150">
    </el-table-column>
    <el-table-column prop="subject" label="学科" width="60">
      <!-- <template slot-scope="{ row }">
        <span v-if="row.subjectID === 1">Java</span>
        <span v-if="row.subjectID === 4">前端</span>
        <span v-if="row.subjectID === 16">11</span>
        <span v-if="row.subjectID === 13">c</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="catalog" label="目录" width="120">
=======
  <el-table :data="list" border style="width: 100%">
    <el-table-column fixed prop="number" label="试题编号" width="150">
    </el-table-column>
    <el-table-column prop="subjectID" label="学科" width="60">
      <template slot-scope="{ row }">
        <span v-if="row.subjectID === 1">Java</span>
        <span v-if="row.subjectID === 4">前端</span>
      </template>
    </el-table-column>
    <el-table-column prop="catalog" label="目录" width="120"> 
>>>>>>> gxd
      <!-- <template slot-scope="{ row }">
        <span v-if="row.catalogID === 5">css基础</span>
        <span v-if="row.catalogID === 2">javaWEB</span>
        <span v-if="row.catalogID === 1">java基础</span>
      </template> -->
    </el-table-column>
    <el-table-column prop="questionType" label="题型" width="100">
      <template slot-scope="{ row }">
        <span v-if="row.questionType === '1'">单选</span>
        <span v-if="row.questionType === '2'">多选</span>
        <span v-if="row.questionType === '3'">简答</span>
      </template>
    </el-table-column>
    <el-table-column prop="question" label="题干" width="100">
      <template slot-scope="{ row }">
        <span v-html="row.question">单选</span>
      </template>
    </el-table-column>
    <el-table-column prop="addDate" label="录入时间" width="120">
    </el-table-column>
    <el-table-column prop="difficulty" label="难度" width="80">
      <template slot-scope="{ row }">
        <span v-if="row.difficulty === '1'">简单</span>
        <span v-if="row.difficulty === '2'">一般</span>
        <span v-if="row.difficulty === '3'">困难</span>
      </template>
    </el-table-column>
    <el-table-column prop="creator" label="录入人" width="120" value>
    </el-table-column>

    <el-table-column label="操作" width="200">
      <template slot-scope="{ row }">
        <el-button
          circle
          plain
          size="small"
          type="primary"
          icon="el-icon-view"
<<<<<<< HEAD
          @click="notification(row)"
=======
>>>>>>> gxd
        ></el-button>
        <el-button
          circle
          plain
          size="small"
          type="success"
          icon="el-icon-edit"
<<<<<<< HEAD
           @click="modify(row.id)"
=======
>>>>>>> gxd
        ></el-button>
        <!-- 1 删除按钮绑定事件 【删除功能】 -->
        <el-button
          @click="deletebtn(row.id)"
          circle
          plain
          size="small"
          type="danger"
          icon="el-icon-delete"
<<<<<<< HEAD
         
        ></el-button>
        <el-button
          @click="Collection(row.id)"
=======
        ></el-button>
        <el-button
        @click="Collection(row.id)"
>>>>>>> gxd
          circle
          size="small"
          type="warning"
          plain
          icon="el-icon-star-off"
        ></el-button>
      </template>
    </el-table-column>
<<<<<<< HEAD
  
  </el-table>
    <!-- 弹窗 -->
    <questions ref="question"></questions>
  </div>
</template>

<script>
import { deleteApi, selectedApi } from "@/api/questionslist";
import questions from "./questions-info.vue";
export default {
  components: {
    questions,
  },
  name: "ChoicePage",
  props: {
    lists: {
      type: Array,
    },
  },
created(){
},
=======
  </el-table>

  <!-- <div>1111</div> -->
</template>

<script>
import {
  deleteApi,
  selectedApi
} from "@/api/list";
export default {
  name: "ChoicePage",
  props: {
    list: {
      type: Array,
    },
  },

>>>>>>> gxd
  data() {
    return {};
  },
  methods: {
<<<<<<< HEAD
    // 删除
    async deletebtn(id) {
      await this.$confirm("此操作将永久删除该文件, 是否继续?", "提示");
      await deleteApi(id);
      this.$message.success("删除成功");
      // if (this.qureyData.page > 1 && this.lists.length === 1) {
      //   this.qureyData.page--;
      // }
      // 页面刷新
      this.$emit("updateList");
      
    },
    // 精选题库上下架
    async Collection(id) {
      console.log(id);
      console.log(this.lists);
      await this.$confirm("此操作将该题目加入精选，是否继续？", "提示");
      await selectedApi(id);
      this.$message.success("加入成功");
      
      // 页面刷新
      this.$emit("updateList");
      if (this.qureyData.page > 1 && this.lists.length === 1) {
        this.qureyData.page--;
      }
    },
    //  弹窗
    notification(row) {
      this.$refs.question.showDialog = true;
      this.$refs.question.info = row;
      console.log(row);
    },
    // 修改
    modify(id){
      this.$router.push({
        query:{
          id: id
        },
        path:"/questions/new"
      })
=======

    // 删除
    async deletebtn(id) {
      await this.$confirm('此操作将永久删除该文件, 是否继续?', '提示');
      await deleteApi(id);
      this.$message.success("删除成功");
      if (this.qureyData.page > 1 && this.list.length === 1) {
        this.qureyData.page--;
      }
      // 页面刷新
      this.$emit('updateList');
    },
    // 精选题库上下架
    async Collection(id){
      console.log(id);
      console.log(this.list);
       await this.$confirm("此操作将该题目加入精选，是否继续？", '提示');
      await selectedApi(id);
      this.$message.success("加入成功");
      if (this.qureyData.page > 1 && this.list.length === 1) {
        this.qureyData.page--;
      }
      // 页面刷新
      this.$emit('updateList');
>>>>>>> gxd
    }
  },
};
</script>

<style>
<<<<<<< HEAD
.el-dialog__header {
 background: #409eff
}
.el-dialog__title{
 color: #fff;
}
=======
>>>>>>> gxd
</style>